<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>检测浏览器是否支持Ajax</title>
</head>
<body>
<script type="text/javascript">
    function createAjax() {
        var ajax = null;
        try {
            // 创建IE
            ajax = new ActiveXObject("microsoft.xmlhttp");
        }catch(e1){
            // 非IE
            ajax = new XMLHttpRequest();
        }
        return ajax;
    }
</script>

<input type="button" id="checkAjax" value="点击检测">

<script type="text/javascript">
    document.getElementById('checkAjax').onclick = function () {
        var aj = createAjax();
        if(aj===null){
            alert("该浏览器不支持异步对象");
        }else {
            alert("你的浏览器支持异步对象");
        }
    }
</script>
</body>
</html>